package com.liangjie.dao;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Log {
	public static void logToFile(Object obj, Exception e) {
		File file = new File("data/log.log");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:ss");
		try {
			BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
			bw.write("-------------------------------------");
			bw.newLine();
			bw.write(sdf.format(new Date()));
			bw.newLine();
			bw.write(obj.getClass().getName());
			bw.newLine();
			bw.write(e.toString());
			bw.newLine();
			bw.write("-------------------------------------");
			bw.newLine();
			bw.flush();
			bw.close();
		} catch (IOException e1) {
			// TODO Auto-generated catch block
			Log.logToFile(Log.class, e1);
		}
	}
}
